function std_dX = CalcTimeSeriesDiffVol(X,prob_X,Phi_X,n,Phi_X_n)
% computes std(X(t+m)-X(t))
    
    if nargin<=4
        Phi_X_n = mpower2(Phi_X,n);
    end
    
    mean_X = sum(prob_X(:).*X(:));
    var_X = sum(prob_X(:).*(X(:).^2)) - mean_X^2;
    
    condE_X_n = Phi_X_n*X(:);
    var_dX = 2*var_X - 2*(sum(prob_X(:).*X(:).*condE_X_n) - mean_X^2);
    std_dX = sqrt(var_dX);


end